package cn.tedu.user.feign;

import cn.tedu.common.ex.ScServiceException;
import cn.tedu.common.util.JWTUtil;
import cn.tedu.common.vo.JsonResult;
import cn.tedu.common.vo.ResponseCode;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/ry/feign/client")
//校验token
public class SSOFeignController {
    @PostMapping("check")
    public JsonResult check(String token){
        log.debug("检查token:{}",token);
        try {
            JWTUtil.verify(token);
            return JsonResult.ok("通过验证");
        }catch (Exception e){
            throw new ScServiceException(ResponseCode.INTERNAL_SERVER_ERROR,"验证未通过");
        }
    }
}
